home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
docs
/
ippon
/
data
/
etc
/
titspark.lzh
/
bomb.c
next >
Wrap
C/C++ Source or Header
|
1998-11-22
|
2KB
|
122 lines
#include <stdlib.h>
#include <stdio.h>
#include <XSP2lib.H>
#include "expl.h"
#include "fxsp2lib.h"
#define BOMB_MAX 32 /* 最大数 */
BOMB *bomb, *bomb_top, *bomb_null_top;
extern int o_option;
int bomb_init0 (void)
{
int i;
if ((bomb = malloc (sizeof (BOMB) * BOMB_MAX)) == NULL)
return (-1);
bomb_top = NULL;
bomb_null_top = bomb;
for (i = 0; i < BOMB_MAX; i++) {
bomb[i].next = &bomb[i + 1];
}
bomb[BOMB_MAX - 1].next = NULL;
return (0);
}
void bomb_init (signed short x, signed short y, signed int vx, signed int vy, char cyc)
{
if (bomb_null_top != NULL) {
BOMB *p;
p = bomb_null_top;
bomb_null_top = p->next;
p->next = bomb_top;
bomb_top = p;
p->lx = x << 16;
p->ly = y << 16;
p->pt = 0;
p->info = 0x023f;
p->vx = vx;
p->vy = vy;
p->cyc = cyc;
p->cyc1 = cyc;
p->cyc2 = 0;
}
}
void bomb_move (void)
{
BOMB *p, *q;
static short pt_table[]=
{3, 2, 1, 0};
p = bomb_top;
q = NULL;
while (p != NULL) {
char erase_flag = 0;
/* 速度を足して上位ワード(固定整数部)だけ取り出す */
p->x = (p->lx += p->vx) >> 16;
p->y = (p->ly += p->vy) >> 16;
p->vx -= p->vx * 0.1; /* 空気抵抗 */
p->vy -= p->vy * 0.1;
p->pt = pt_table[p->cyc2];
if (--p->cyc1 <= 0) {
p->cyc1 = p->cyc;
if (++p->cyc2 > 4)
erase_flag = !0;
}
if (erase_flag) {
if (q == NULL) { /* リストの一番最初を削除 */
bomb_top = p->next;
p->next = bomb_null_top;
bomb_null_top = p;
q = NULL;
p = bomb_top;
} else {
q->next = p->next;
p->next = bomb_null_top;
bomb_null_top = p;
p = q->next;
}
} else {
p->x += (128 + 16); /* 表示用に補正 */
p->y += (128 + 16);
p->x -= 8;
p->y -= 8;
xsp_set_st (p);
p->x -= (128 + 16);
p->y -= (128 + 16);
fxsp_set_st (p);
p->x += 8;
p->y += 8;
q = p;
p = p->next;
}
}
}
void bomb_tini (void)
{
int i;
bomb_top = NULL;
bomb_null_top = bomb;
for (i = 0; i < BOMB_MAX; i++) {
bomb[i].next = &bomb[i + 1];
}
bomb[BOMB_MAX - 1].next = NULL;
}